package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteDictService;
import com.ruoyi.system.api.domain.RemoteSysDictData;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class RemoteDictFallbackFactory implements FallbackFactory<RemoteDictService> {
    @Override
    public RemoteDictService create(Throwable throwable) {
        log.error("字典服务调用失败:{}", throwable.getMessage());
        return new RemoteDictService() {
            /**
             * 根据类型查询字典值
             *
             * @param dictType 字典类型
             * @return 结果
             */
            @Override
            public R<List<RemoteSysDictData>> getDictDatas(String dictType) {
                return null;
            }

            @Override
            public R insertDictData(String dictType, String dictData) {
                return null;
            }
        };
    }
}
